/*
 * Decompiled with CFR 0.150.
 * 
 * Could not load the following classes:
 *  cn.hutool.core.date.DateUtil
 *  cn.hutool.core.util.ObjectUtil
 *  cn.hutool.core.util.StrUtil
 *  com.alibaba.fastjson.JSON
 *  de.felixroske.jfxsupport.FXMLController
 *  javafx.beans.value.ChangeListener
 *  javafx.beans.value.ObservableValue
 *  javafx.fxml.FXML
 *  javafx.fxml.Initializable
 *  javafx.scene.control.Alert
 *  javafx.scene.control.Alert$AlertType
 *  javafx.scene.control.Button
 *  javafx.scene.control.ChoiceBox
 *  javafx.scene.control.DatePicker
 *  javafx.scene.control.ScrollPane
 *  javafx.scene.control.TextField
 *  javafx.scene.layout.AnchorPane
 *  javafx.scene.layout.VBox
 *  javafx.util.StringConverter
 *  org.springframework.beans.factory.annotation.Autowired
 */
package com.gys.controller.cashPayment;

import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.gys.common.business.CashPaymentUtil;
import com.gys.common.data.HttpJson;
import com.gys.common.util.CommonUtil;
import com.gys.controller.BaseController;
import com.gys.controller.cashPayment.AddCashPaymentController;
import com.gys.data.cashPayment.CashPaymentDetailOutData;
import com.gys.data.saleScheduleSetting.GetSaleScheduleOutData;
import com.gys.data.saleScheduleSetting.GetSaleScheduleQueryInData;
import com.gys.data.user.GetEmpOutData;
import com.gys.data.user.GetLoginOutData;
import de.felixroske.jfxsupport.FXMLController;
import java.net.URL;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.ResourceBundle;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Alert;
import javafx.scene.control.Button;
import javafx.scene.control.ChoiceBox;
import javafx.scene.control.DatePicker;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.layout.AnchorPane;
import javafx.scene.layout.VBox;
import javafx.util.StringConverter;
import org.springframework.beans.factory.annotation.Autowired;

@FXMLController
public class AddDetailController
extends BaseController
implements Initializable {
    @FXML
    private AnchorPane anchorPane;
    @FXML
    private VBox vBox;
    @FXML
    private TextField detailAmt;
    @FXML
    private ChoiceBox<GetEmpOutData> detailEmp;
    @FXML
    private ScrollPane scrollPane;
    @FXML
    private DatePicker detailSaleDate;
    @FXML
    private Button cancelBtn;
    @FXML
    private ChoiceBox<GetSaleScheduleOutData> detailEmpGroup;
    @FXML
    private Button sureBtn;
    @Autowired
    private AddCashPaymentController addCashPaymentController;
    List<GetSaleScheduleOutData> empGroupList = new ArrayList<GetSaleScheduleOutData>();
    List<GetEmpOutData> empList = new ArrayList<GetEmpOutData>();

    public void initialize(URL location, ResourceBundle resources) {
        StringConverter converter = CommonUtil.dataPickerFormat("yyyyMMdd");
        this.detailSaleDate.setConverter(converter);
        this.detailSaleDate.setConverter(converter);
        GetSaleScheduleQueryInData inData = new GetSaleScheduleQueryInData();
        HttpJson rsp = CashPaymentUtil.empGroupList(inData);
        if (rsp.isSuccess()) {
            this.empGroupList = JSON.parseArray((String)rsp.getMsg(), GetSaleScheduleOutData.class);
            this.detailEmpGroup.getItems().addAll(this.empGroupList);
            this.detailEmpGroup.converterProperty().set(new StringConverter<GetSaleScheduleOutData>(){

                public String toString(GetSaleScheduleOutData object) {
                    return object.getGsegName();
                }

                public GetSaleScheduleOutData fromString(String string) {
                    return null;
                }
            });
        } else {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp.getMsg());
            alert.showAndWait();
        }
        GetLoginOutData inData2 = new GetLoginOutData();
        HttpJson rsp2 = CashPaymentUtil.empList(inData2);
        if (rsp2.isSuccess()) {
            this.empList = JSON.parseArray((String)rsp2.getMsg(), GetEmpOutData.class);
            this.detailEmp.getItems().addAll(this.empList);
            this.detailEmp.converterProperty().set(new StringConverter<GetEmpOutData>(){

                public String toString(GetEmpOutData object) {
                    return object.getName();
                }

                public GetEmpOutData fromString(String string) {
                    return null;
                }
            });
        } else {
            Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", rsp2.getMsg());
            alert.showAndWait();
        }
        this.detailEmpGroup.valueProperty().addListener(new ChangeListener(){

            public void changed(ObservableValue observable, Object oldValue, Object newValue) {
                String emp5;
                String emp4;
                String emp3;
                String emp2;
                if (ObjectUtil.isNull(AddDetailController.this.detailEmpGroup.getValue())) {
                    AddDetailController.this.detailEmp.getItems().clear();
                    return;
                }
                String value = ((GetSaleScheduleOutData)AddDetailController.this.detailEmpGroup.getValue()).getGsegName();
                ArrayList<GetEmpOutData> empOutList = new ArrayList<GetEmpOutData>();
                String emp1 = ((GetSaleScheduleOutData)AddDetailController.this.detailEmpGroup.getValue()).getGsegEmp1();
                if (StrUtil.isNotBlank((CharSequence)emp1)) {
                    GetEmpOutData outData = new GetEmpOutData();
                    outData.setName(emp1);
                    empOutList.add(outData);
                }
                if (StrUtil.isNotBlank((CharSequence)(emp2 = ((GetSaleScheduleOutData)AddDetailController.this.detailEmpGroup.getValue()).getGsegEmp2()))) {
                    GetEmpOutData outData = new GetEmpOutData();
                    outData.setName(emp2);
                    empOutList.add(outData);
                }
                if (StrUtil.isNotBlank((CharSequence)(emp3 = ((GetSaleScheduleOutData)AddDetailController.this.detailEmpGroup.getValue()).getGsegEmp3()))) {
                    GetEmpOutData outData = new GetEmpOutData();
                    outData.setName(emp3);
                    empOutList.add(outData);
                }
                if (StrUtil.isNotBlank((CharSequence)(emp4 = ((GetSaleScheduleOutData)AddDetailController.this.detailEmpGroup.getValue()).getGsegEmp4()))) {
                    GetEmpOutData outData = new GetEmpOutData();
                    outData.setName(emp4);
                    empOutList.add(outData);
                }
                if (StrUtil.isNotBlank((CharSequence)(emp5 = ((GetSaleScheduleOutData)AddDetailController.this.detailEmpGroup.getValue()).getGsegEmp5()))) {
                    GetEmpOutData outData = new GetEmpOutData();
                    outData.setName(emp5);
                    empOutList.add(outData);
                }
                AddDetailController.this.empList.clear();
                AddDetailController.this.empList.addAll(empOutList);
                AddDetailController.this.detailEmp.getItems().clear();
                AddDetailController.this.detailEmp.getItems().addAll(AddDetailController.this.empList);
            }
        });
        this.init();
    }

    @Override
    public void init() {
        if (ObjectUtil.isEmpty(this.scrollPane)) {
            return;
        }
        this.detailSaleDate.setValue(null);
        this.detailEmpGroup.setValue(null);
        this.detailEmp.setValue(new GetEmpOutData());
        this.detailAmt.clear();
    }

    @FXML
    void sureAction() {
        Alert alert = this.createAlert(Alert.AlertType.INFORMATION, "\u63d0\u793a\u4fe1\u606f", null);
        if (ObjectUtil.isEmpty(this.detailSaleDate.getValue())) {
            alert.setContentText("\u8bf7\u586b\u5199\u9500\u552e\u65e5\u671f");
            alert.showAndWait();
            return;
        }
        if (ObjectUtil.isEmpty(this.detailEmpGroup.getValue())) {
            alert.setContentText("\u8bf7\u9009\u62e9\u73ed\u6b21");
            alert.showAndWait();
            return;
        }
        if (ObjectUtil.isEmpty(this.detailEmp.getValue())) {
            alert.setContentText("\u8bf7\u9009\u62e9\u6536\u94f6\u5458");
            alert.showAndWait();
            return;
        }
        if (ObjectUtil.isEmpty(this.detailAmt.getText())) {
            alert.setContentText("\u8bf7\u586b\u5199\u73b0\u91d1\u5b9e\u6536\u91d1\u989d");
            alert.showAndWait();
            return;
        }
        CashPaymentDetailOutData detailOutData = new CashPaymentDetailOutData();
        detailOutData.setGsddSaleDate(DateUtil.format((Date)DateUtil.parse((String)((LocalDate)this.detailSaleDate.getValue()).toString()), (String)"yyyyMMdd"));
        detailOutData.setGsddEmpGroup(((GetSaleScheduleOutData)this.detailEmpGroup.getValue()).getGsegName());
        detailOutData.setGsddEmp(((GetEmpOutData)this.detailEmp.getValue()).getName());
        detailOutData.setGsddRmbAmt(this.detailAmt.getText().trim());
        this.addCashPaymentController.addDetail(detailOutData);
        this.scrollPane.getScene().getWindow().hide();
    }

    @FXML
    void cancelAction() {
        this.scrollPane.getScene().getWindow().hide();
    }

    public AnchorPane getAnchorPane() {
        return this.anchorPane;
    }

    public VBox getVBox() {
        return this.vBox;
    }

    public TextField getDetailAmt() {
        return this.detailAmt;
    }

    public ChoiceBox<GetEmpOutData> getDetailEmp() {
        return this.detailEmp;
    }

    public ScrollPane getScrollPane() {
        return this.scrollPane;
    }

    public DatePicker getDetailSaleDate() {
        return this.detailSaleDate;
    }

    public Button getCancelBtn() {
        return this.cancelBtn;
    }

    public ChoiceBox<GetSaleScheduleOutData> getDetailEmpGroup() {
        return this.detailEmpGroup;
    }

    public Button getSureBtn() {
        return this.sureBtn;
    }

    public AddCashPaymentController getAddCashPaymentController() {
        return this.addCashPaymentController;
    }

    public List<GetSaleScheduleOutData> getEmpGroupList() {
        return this.empGroupList;
    }

    public List<GetEmpOutData> getEmpList() {
        return this.empList;
    }

    public void setAnchorPane(AnchorPane anchorPane) {
        this.anchorPane = anchorPane;
    }

    public void setVBox(VBox vBox) {
        this.vBox = vBox;
    }

    public void setDetailAmt(TextField detailAmt) {
        this.detailAmt = detailAmt;
    }

    public void setDetailEmp(ChoiceBox<GetEmpOutData> detailEmp) {
        this.detailEmp = detailEmp;
    }

    public void setScrollPane(ScrollPane scrollPane) {
        this.scrollPane = scrollPane;
    }

    public void setDetailSaleDate(DatePicker detailSaleDate) {
        this.detailSaleDate = detailSaleDate;
    }

    public void setCancelBtn(Button cancelBtn) {
        this.cancelBtn = cancelBtn;
    }

    public void setDetailEmpGroup(ChoiceBox<GetSaleScheduleOutData> detailEmpGroup) {
        this.detailEmpGroup = detailEmpGroup;
    }

    public void setSureBtn(Button sureBtn) {
        this.sureBtn = sureBtn;
    }

    public void setAddCashPaymentController(AddCashPaymentController addCashPaymentController) {
        this.addCashPaymentController = addCashPaymentController;
    }

    public void setEmpGroupList(List<GetSaleScheduleOutData> empGroupList) {
        this.empGroupList = empGroupList;
    }

    public void setEmpList(List<GetEmpOutData> empList) {
        this.empList = empList;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof AddDetailController)) {
            return false;
        }
        AddDetailController other = (AddDetailController)o;
        if (!other.canEqual(this)) {
            return false;
        }
        AnchorPane this$anchorPane = this.getAnchorPane();
        AnchorPane other$anchorPane = other.getAnchorPane();
        if (this$anchorPane == null ? other$anchorPane != null : !this$anchorPane.equals(other$anchorPane)) {
            return false;
        }
        VBox this$vBox = this.getVBox();
        VBox other$vBox = other.getVBox();
        if (this$vBox == null ? other$vBox != null : !this$vBox.equals(other$vBox)) {
            return false;
        }
        TextField this$detailAmt = this.getDetailAmt();
        TextField other$detailAmt = other.getDetailAmt();
        if (this$detailAmt == null ? other$detailAmt != null : !this$detailAmt.equals(other$detailAmt)) {
            return false;
        }
        ChoiceBox<GetEmpOutData> this$detailEmp = this.getDetailEmp();
        ChoiceBox<GetEmpOutData> other$detailEmp = other.getDetailEmp();
        if (this$detailEmp == null ? other$detailEmp != null : !this$detailEmp.equals(other$detailEmp)) {
            return false;
        }
        ScrollPane this$scrollPane = this.getScrollPane();
        ScrollPane other$scrollPane = other.getScrollPane();
        if (this$scrollPane == null ? other$scrollPane != null : !this$scrollPane.equals(other$scrollPane)) {
            return false;
        }
        DatePicker this$detailSaleDate = this.getDetailSaleDate();
        DatePicker other$detailSaleDate = other.getDetailSaleDate();
        if (this$detailSaleDate == null ? other$detailSaleDate != null : !this$detailSaleDate.equals(other$detailSaleDate)) {
            return false;
        }
        Button this$cancelBtn = this.getCancelBtn();
        Button other$cancelBtn = other.getCancelBtn();
        if (this$cancelBtn == null ? other$cancelBtn != null : !this$cancelBtn.equals(other$cancelBtn)) {
            return false;
        }
        ChoiceBox<GetSaleScheduleOutData> this$detailEmpGroup = this.getDetailEmpGroup();
        ChoiceBox<GetSaleScheduleOutData> other$detailEmpGroup = other.getDetailEmpGroup();
        if (this$detailEmpGroup == null ? other$detailEmpGroup != null : !this$detailEmpGroup.equals(other$detailEmpGroup)) {
            return false;
        }
        Button this$sureBtn = this.getSureBtn();
        Button other$sureBtn = other.getSureBtn();
        if (this$sureBtn == null ? other$sureBtn != null : !this$sureBtn.equals(other$sureBtn)) {
            return false;
        }
        AddCashPaymentController this$addCashPaymentController = this.getAddCashPaymentController();
        AddCashPaymentController other$addCashPaymentController = other.getAddCashPaymentController();
        if (this$addCashPaymentController == null ? other$addCashPaymentController != null : !(this$addCashPaymentController).equals(other$addCashPaymentController)) {
            return false;
        }
        List<GetSaleScheduleOutData> this$empGroupList = this.getEmpGroupList();
        List<GetSaleScheduleOutData> other$empGroupList = other.getEmpGroupList();
        if (this$empGroupList == null ? other$empGroupList != null : !(this$empGroupList).equals(other$empGroupList)) {
            return false;
        }
        List<GetEmpOutData> this$empList = this.getEmpList();
        List<GetEmpOutData> other$empList = other.getEmpList();
        return !(this$empList == null ? other$empList != null : !(this$empList).equals(other$empList));
    }

    protected boolean canEqual(Object other) {
        return other instanceof AddDetailController;
    }

    public int hashCode() {
        int PRIME = 59;
        int result = 1;
        AnchorPane $anchorPane = this.getAnchorPane();
        result = result * 59 + ($anchorPane == null ? 43 : $anchorPane.hashCode());
        VBox $vBox = this.getVBox();
        result = result * 59 + ($vBox == null ? 43 : $vBox.hashCode());
        TextField $detailAmt = this.getDetailAmt();
        result = result * 59 + ($detailAmt == null ? 43 : $detailAmt.hashCode());
        ChoiceBox<GetEmpOutData> $detailEmp = this.getDetailEmp();
        result = result * 59 + ($detailEmp == null ? 43 : $detailEmp.hashCode());
        ScrollPane $scrollPane = this.getScrollPane();
        result = result * 59 + ($scrollPane == null ? 43 : $scrollPane.hashCode());
        DatePicker $detailSaleDate = this.getDetailSaleDate();
        result = result * 59 + ($detailSaleDate == null ? 43 : $detailSaleDate.hashCode());
        Button $cancelBtn = this.getCancelBtn();
        result = result * 59 + ($cancelBtn == null ? 43 : $cancelBtn.hashCode());
        ChoiceBox<GetSaleScheduleOutData> $detailEmpGroup = this.getDetailEmpGroup();
        result = result * 59 + ($detailEmpGroup == null ? 43 : $detailEmpGroup.hashCode());
        Button $sureBtn = this.getSureBtn();
        result = result * 59 + ($sureBtn == null ? 43 : $sureBtn.hashCode());
        AddCashPaymentController $addCashPaymentController = this.getAddCashPaymentController();
        result = result * 59 + ($addCashPaymentController == null ? 43 : ($addCashPaymentController).hashCode());
        List<GetSaleScheduleOutData> $empGroupList = this.getEmpGroupList();
        result = result * 59 + ($empGroupList == null ? 43 : ($empGroupList).hashCode());
        List<GetEmpOutData> $empList = this.getEmpList();
        result = result * 59 + ($empList == null ? 43 : ($empList).hashCode());
        return result;
    }

    public String toString() {
        return "AddDetailController(anchorPane=" + this.getAnchorPane() + ", vBox=" + this.getVBox() + ", detailAmt=" + this.getDetailAmt() + ", detailEmp=" + this.getDetailEmp() + ", scrollPane=" + this.getScrollPane() + ", detailSaleDate=" + this.getDetailSaleDate() + ", cancelBtn=" + this.getCancelBtn() + ", detailEmpGroup=" + this.getDetailEmpGroup() + ", sureBtn=" + this.getSureBtn() + ", addCashPaymentController=" + this.getAddCashPaymentController() + ", empGroupList=" + this.getEmpGroupList() + ", empList=" + this.getEmpList() + ")";
    }
}

